﻿GetJson(){

$.getJSON("http://localhost:53425/api/KPI/jsonp?callback=?", function (data) {          //Get jsonp data, pass to function


    var indexOutput = '';                                                               //content container

    for (var i in data) {                                                               //iterate over jsonp objects


        if (data[i].currentValue > data[i].lastValue) {                                //logic to set indicator image for kpi tile

            var img = "<img src=\"img/arrowup.png\"></img>";
        }

        else if (data[i].currentValue < data[i].lastValue) {

            var img = "<img src=\"img/arrowdown.png\"></img>";
        }

        else {
            var img = "<img src=\"img/sameicon.png\"></img>";
        }

        var link = '<a href=\"';                                                //Formats jQuery mobile Listview tiles and populates countainer with Jsonp data
        link += '#details';
        link += '\" onclick="content(' + data[i].iD + ');return false;">';

        indexOutput += "<li data-icon=\"false\">";                          //Page 1 - tiles with summary for each kpi
        indexOutput += link;
        indexOutput += "<h1>" + data[i].name + "</h1>";
        indexOutput += "<h3>" + numberToCurrency(data[i].currentValue) + "</h3>";
        indexOutput += img;
        indexOutput += "</a></li>";
        indexOutput += "</ul>";
        indexOutput += "</li>";
    }

    $("#kpi").append(indexOutput);                                              //send content to page, refresh listview as last task
    $("#kpi").listview('refresh');
});
}